//package com.ruoyi.flowable.listener;
//
//
//import com.ruoyi.flowable.common.util.ApplicationContextHelperUtil;
//import lombok.extern.slf4j.Slf4j;
//import org.flowable.engine.RuntimeService;
//import org.flowable.engine.TaskService;
//import org.flowable.engine.delegate.TaskListener;
//import org.flowable.task.api.Task;
//import org.flowable.task.service.delegate.DelegateTask;
//import org.springframework.stereotype.Component;
//
//@Slf4j
//@Component
//public class CountersignListener implements TaskListener {
//
//    @Override
//    public void notify(DelegateTask delegateTask) {
//        RuntimeService runtimeService = ApplicationContextHelperUtil.getBean(RuntimeService.class);
//        TaskService taskService = ApplicationContextHelperUtil.getBean(TaskService.class);
//        log.info("会签监听器:{}", delegateTask);
//        String exId = delegateTask.getExecutionId();
//        Integer pass = (Integer) runtimeService.getVariable(exId, "pass");
//        if (pass != null && pass == 0) {
//            runtimeService.setVariable(exId, "out", 0);
//        } else if (pass != null && pass == 1) {
//            Integer complete = (Integer) runtimeService.getVariable(exId, "nrOfCompletedInstances");
//            Integer all = (Integer) runtimeService.getVariable(exId, "nrOfInstances");
//            if ((complete + 1) / all == 1) {
//                String processInstanceId = delegateTask.getProcessInstanceId();
//                runtimeService.setVariable(exId, "out", 1);
//                Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();
//                System.out.println("全部完成,会签通过---节点为:" + task.getName());
//            }
//        }
//    }
//}
